import { resolve } from "path"
import { defineConfig } from "vite"
import vue from "@vitejs/plugin-vue"
import vueJsx from "@vitejs/plugin-vue-jsx"
import svgLoader from "vite-svg-loader"
import configArcoStyleImportPlugin from "./plugin/arcoStyleImport"
import UnoCSS from "unocss/vite"
import eslintPlugin from "vite-plugin-eslint"

export default defineConfig({
  plugins: [
    vue(),
    vueJsx(),
    svgLoader({ svgoConfig: {} }),
    configArcoStyleImportPlugin(),
    UnoCSS(),
    eslintPlugin({
      // 设置 failOnError 为 false 以忽略所有的 ESLint 报错
      failOnError: false,
      // 设置 failOnWarning 为 false 以忽略所有的 ESLint 警告
      failOnWarning: true
    })
  ],
  resolve: {
    alias: [
      {
        find: "@",
        replacement: resolve(__dirname, "../src")
      },
      {
        find: "assets",
        replacement: resolve(__dirname, "../src/assets")
      },
      {
        find: "vue-i18n",
        replacement: "vue-i18n/dist/vue-i18n.cjs.js" // Resolve the i18n warning issue
      },
      {
        find: "vue",
        replacement: "vue/dist/vue.esm-bundler.js" // compile template
      }
    ],
    extensions: [".ts", ".js"]
  },
  define: {
    "process.env": {}
  },
  css: {
    preprocessorOptions: {
      less: {
        modifyVars: {
          hack: `true; @import (reference) "${resolve("src/assets/style/breakpoint.less")}";`
        },
        javascriptEnabled: true
      }
    }
  }
})
